package com.unbank.entity;

import java.util.Date;

import javax.ws.rs.FormParam;
import javax.ws.rs.HeaderParam;
import javax.xml.bind.annotation.XmlRootElement;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.unbank.db.mybatis.vo.Crawl;
import com.unbank.db.mybatis.vo.CrawlText;
import com.unbank.db.mybatis.vo.Website;

@XmlRootElement(name = "news")
public class News {
	
	/**
	 * 新闻ID
	 */
	@HeaderParam("crawl_id")
	private int crawl_id;
	/**
	 * 新闻URL
	 */
	@FormParam("url")
	private String url;
	/**
	 * 新闻标题
	 */
	@FormParam("title")
	private String title;
	/**
	 * 新闻内容
	 */
	@FormParam("content")
	private String content;
	/**
	 * 新闻时间
	 */
	@FormParam("newsDate")
	private Long newsDate;
	/**
	 * 新闻抓取时间
	 */
	@FormParam("crawlDate")
	private Long crawlDate;
	/**
	 * 新闻来源网站名称
	 */
	@FormParam("webName")
	private String webName;
	/**
	 * 新闻来源板块名称
	 */
	@FormParam("webSectionName")
	private String webSectionName;
	/**
	 * 新闻来源对应的Website_id
	 */
	@FormParam("website_id")
	private int website_id;
	/**
	 * 是否是精确抓取的
	 */
	@FormParam("isTask")
	private int isTask;
	/**
	 * 新闻来源（信息源）的URL
	 */
	@FormParam("p_url")
	private String p_url;
	/**
	 * 新闻所属标签名称
	 */
	@FormParam("tagName")
	private String tagName;
	/**
	 * 新闻关键词
	 */
	@FormParam("keyWords")
	private String keyWords;
	
	
	public String getTagName() {
		return tagName;
	}

	public void setTagName(String tagName) {
		this.tagName = tagName;
	}

	public String getKeyWords() {
		return keyWords;
	}

	public void setKeyWords(String keyWords) {
		this.keyWords = keyWords;
	}

	public int getCrawl_id() {
		return crawl_id;
	}

	public void setCrawl_id(int crawl_id) {
		this.crawl_id = crawl_id;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public int getIsTask() {
		return isTask;
	}

	public void setIsTask(int isTask) {
		this.isTask = isTask;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}


	public Long getNewsDate() {
		return newsDate;
	}

	public void setNewsDate(Long newsDate) {
		this.newsDate = newsDate;
	}

	public Long getCrawlDate() {
		return crawlDate;
	}

	public void setCrawlDate(Long crawlDate) {
		this.crawlDate = crawlDate;
	}

	public String getWebName() {
		return webName;
	}

	public void setWebName(String webName) {
		this.webName = webName;
	}

	public String getWebSectionName() {
		return webSectionName;
	}

	public void setWebSectionName(String webSectionName) {
		this.webSectionName = webSectionName;
	}

	public int getWebsite_id() {
		return website_id;
	}

	public void setWebsite_id(int website_id) {
		this.website_id = website_id;
	}
	
	public String getP_url() {
		return p_url;
	}

	public void setP_url(String p_url) {
		this.p_url = p_url;
	}

	public void setCrawl(Crawl crawl) {
		this.crawl_id=crawl.getCrawlId();
		this.url=crawl.getUrl();
		this.title=crawl.getCrawlTitle();
	}

	public void setCrawlText(CrawlText crawlText) {
		this.content=crawlText.getText();
	}

	public void setWebsite(Website website) {
		this.webName=website.getWebName();
		this.website_id=website.getWebsiteId();
		this.webSectionName=website.getSectionName();
		this.p_url=website.getUrlHome();
		this.isTask=website.getIstask();
	}
	
	public String toJsonString(){
		ObjectMapper mapper = new ObjectMapper(); 
		try {
			String json = mapper.writeValueAsString(this);
			return json;
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public String toString() {
		return "News [crawl_id=" + crawl_id + ", url=" + url + ", title=" + title + ", content=" + content
				+ ", newsDate=" + newsDate + ", crawlDate=" + crawlDate + ", webName=" + webName + ", webSectionName="
				+ webSectionName + ", website_id=" + website_id + ", isTask=" + isTask + ", p_url=" + p_url + "]";
	}
	
}
